<?php

class percentbar {
	
	var $default_img;
	var $default_bg;
	
	
	function percentbar($default_img = '../modules/percentbar/percentbar.gif', $dafult_bg = '../modules/percentbar/percentbar_bg.gif') {
		$this->default_img = $default_img;
		$this->default_bg  = $default_bg;
	}
	
	function insert($percent) {
		if (is_numeric($percent) && $percent >= 0 && $percent <= 100) {
			//$percent = round($percent);
			$w = round((($percent / 100) * 121) - 121);
			$out  = '<img src="'. $this->default_bg .'" alt="'. $percent .'%" ';
			$out .= 'style="background: white url('. $this->default_img .') top left no-repeat; padding: 0; margin: 5px 0 0 0; background-position: 1px 0; background-position: '.$w.'px 0;" />';
		}
		return $out;
	}
}

?>